{% extends '/pg/index.html' %}
{% block operation %}
<ul class="breadcrumb">
  <li><a href="/pg">Home</a></li>
  <li><a href="/pg/ac_Rilevazioni">Rilevazioni</a></li>
  <li class="active">Elenco Rilevazioni</li>
</ul>
<h2 class="text-center">Elenco rilevazioni {{schemaa}}</h2>

{% include "pg/btn_action.html" with context %}
<button type="button" id="import_csv" class="btn btn-danger">Import Csv</button>
<button type="button" id="multi_report" class="btn btn-info">Report</button>
<button type="button" id="multi_delete" class="btn btn-info">Cancella tutti</button>
<button type="button" id="export" class="btn btn-info">Export</button>
<button type="button" id="ordina" class="btn btn-danger">Ordina</button>

{% include "pg/filterkey/fk_rilevazioni.html" with context %}

{%endblock%}

{% block custom_js %}
<script type="text/javascript">
$(document).ready(function () {

$(".Preview").hide()
$("#anteprima").hide()
$(".Edit_dao").hide()
$("#edit_dao").hide()
$("#print_dao").hide()
        $("#multi_report").hide()
        $("#multi_delete").hide()

$('#tableContainer_ac').jtable({
    title: 'Tabella Rilevazioni ',
    messages: window.italianMessages,
    defaultDateFormat:"dd-mm-yy",
    paging: true,
    pageSize: 20,
    sorting: true,
    selecting: true,
    create:false,
    multiselect: true,
    selectingCheckboxes: true,

    actions: {
        listAction: '/pg/ac_Rilevazioni/List',
            {% if pageData["role"]|lower =="admin" %}
        deleteAction: '/pg/ac_Rilevazioni/Delete'
            {% endif %}
    },

    fields: {
        id: {key: true, create: false, edit: false, list: false },
        data_inserimento: { title: 'Data Inserimento', width: '4%',},
        ente: { title: 'Ente', width: '4%',},
        categoria: { title: 'Categoria', width: '8%', },
        catalogo: { title: 'Catalogo', width: '4%',
                        display: function (data) {
                return data.record.catalogo;
                }},
        titolo: { title: 'Info', width: '18%',
                    display: function (data) {
                return data.record.titolo;
                }},
        operatore: { title: 'Operatore', width: '10%', },
        esported: { title: 'Esportata', width: '2%', },
    },
    selectionChanged: function () {
    //Get all selected rows

    var $selectedRows = $('#tableContainer_ac').jtable('selectedRows');
    $("#anteprima").hide();
    $(".Preview").empty();
    $("#print_dao").hide();
    $("#edit_dao").hide();
    //$("#export").hide();

    if ($selectedRows.length == 1) {
        //Show selected rows
        $("#edit_dao").show()
        $("#anteprima").show()
        $("#export").show()
        //$("#print_dao").show()
        $("#multi_report").hide()
        $("#multi_delete").hide()


    } else if ($selectedRows.length > 1) {
        $("#edit_dao").hide()
        $("#anteprima").hide()
        $("#multi_report").show()
        $("#multi_delete").show()
        $("#export").show()
        }

},

}); //fine tabella

$( "#fk_dadata" ).datetimepicker( $.datepicker.regional[ "it" ] );
$( "#fk_adata" ).datetimepicker( $.datepicker.regional[ "it" ] );


filtra = function() {
    $('#tableContainer_ac').jtable('load', {
        fk_id_ente: $('#fk_id_ente').val(),
        fk_id_categoria: $('#fk_id_categoria').val(),
        fk_dadata: $('#fk_dadata').val(),
        fk_adata: $('#fk_adata').val(),
    });
  };

$('#tableContainer_ac').jtable('load');
$('#anteprima').attr('preview', '/pg/ac_Rilevazioni/Preview');
$('#new_dao').attr('nuovo_dao', '/pg/ac_Rilevazioni/Edit');
$('#edit_dao').attr('modifica_dao', '/pg/ac_Rilevazioni/Edit');
$('#import_csv').attr('importa_csv', '/pg/ac_Rilevazioni/ImportCsvCreate');
$('#multi_delete').attr('multi_cancella', '/pg/ac_Rilevazioni/MultiDelete');
$('#multi_report').attr('multi_reportt', '/pg/ac_Rilevazioni/MultiReport');
$('#export').attr('esport', '/pg/ac_Rilevazioni/ExportParam');
$('#ordina').attr('ordinaa', '/pg/ac_Rilevazioni/Ordina');
categ_dao_cate()
//getente()
});
</script>
{% endblock %}
